#ifndef QDEVICECLIENT_H
#define QDEVICECLIENT_H

#include <QObject>
#include <QUdpSocket>
#include <QDateTime>
#include <QTimer>

struct tagDeviceInfo;
struct tagServerInfo;

class QDeviceClient : public QObject
{
    Q_OBJECT
public:
    explicit QDeviceClient(tagDeviceInfo *info,QObject *parent = 0);
    ~QDeviceClient();
    void    search(int addr=-1);

    void    send_data(const QByteArray & data,int addr);
signals:
    void    server_offline(const QString &uuid);
    void    server_online(tagServerInfo* info);
    void    recv_data(const QByteArray &data);
protected slots:
    void    read();
    void    send_read();
    void    hand_timer();
protected:
    tagDeviceInfo           *m_device_info;
    QMap<QString,QDateTime> m_server_hand;
    QUdpSocket              *m_socket;
    QUdpSocket              *m_send_recv_socket;
    QTimer                  *m_timer;
    QDateTime               m_last_send_time;
};

#endif // QDEVICECLIENT_H
